<?php

class Sala{
	public $IdSala;
	public $Nombre;

	
	function __construct($row){
		$this->IdSala = $row['IdSala'];
		$this->Nombre = $row['Nombre'];
	}
	
	static function Listar(){
		global $dbh;
		
		$sql = 'SELECT IdSala,Nombre  FROM Sala';
		$lista = array();
		 
		foreach($dbh->query($sql) as $row) {
			$lista[] = new Sala($row);
		}
		
		return $lista;
	}
	
	static function Obtener($id){
		global $dbh;
		
		$sql = 'SELECT IdSala,Nombre FROM `Sala` WHERE `IdSala` = '.$id;
		
		$tp = NULL;
		foreach($dbh->query($sql) as $row){
			$tp = new Sala($row);	
		}		
		return $tp;			
	}
	
}
?>
